<template>
  <div class="node-panel">
    <template v-for="(value, key, index) in nodeData">
      <div class="node-name">{{ key }}</div>
      <div class="node-list">
        <div
          class="node-item"
          v-for="item in value"
          :key="item.text"
          @mousedown="$_dragNode(item)"
        >
          <div class="node-item-icon" :class="item.class">
          </div>
          <span class="node-label">{{ item.text }}</span>
        </div>
      </div>
    </template>
  </div>
</template>
<script>
export default {
  name: "NodePanel",
  props: {
    lf: Object,
    nodeList: Array,
  },
  data() {
    return {};
  },
  computed: {
    nodeData() {
      return {
          基础组件: [
            {
              text: "开始节点",
              type: "startNode",
              class: "node-startNode",
            },
            {
              text: "普通节点",
              type: "dataExtraction",
              class: "node-dataExtraction",
            },
            {
              text: "合并节点",
              type: "dataMerge",
              class: "node-paramsSplicing",
            },
          ],
        }
    },
  },
  methods: {
    $_dragNode(item) {
      this.$props.lf.dnd.startDrag({
        type: item.type,
        text: item.text,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.node-panel {
  position: absolute;
  top: 50px;
  left: 20px;
  width: 240px;
  height: 510px;
  padding: 20px 10px;
  background-color: white;
  box-shadow: 0 0 10px 1px rgb(228, 224, 219);
  border-radius: 6px;
  text-align: center;
  z-index: 101;
  .node-list {
    width: 240px;
    display: flex;
    //flex-direction: column;
    flex-wrap: wrap;
  }
  .node-name {
    text-align: left;
    margin-bottom: 15px;
  }
}
.node-item {
  width: 70px;
  margin-bottom: 10px;
}
.node-item-icon {
  width: 30px;
  height: 30px;
  margin-left: 20px;
  background-size: cover;
}
.node-label {
  font-size: 12px;
  margin-top: 5px;
  user-select: none;
}
.node-startNode {
  background: url("../background/start.svg") no-repeat;
  background-size: cover;
}
.node-dataExtraction {
  background: url("../background/u1239.svg") no-repeat;
  background-size: cover;
}
.node-screen {
  background: url("../background/u1240.svg") no-repeat;
  background-size: cover;
}
.node-nullValueFill {
  background: url("../background/u1241.svg") no-repeat;
  background-size: cover;
}

.node-catchValueCorrect {
  background: url("../background/u1242.svg") no-repeat;
  background-size: cover;
}

.node-dataClustering {
  background: url("../background/u1244.svg") no-repeat;
  background-size: cover;
}

.node-paramsSplicing {
  background: url("../background/u305.svg") no-repeat;
  background-size: cover;
}

.node-dataSort {
  background: url("../background/u237.svg") no-repeat;
  background-size: cover;
}
.node-lineModel {
  background: url("../background/u1247.svg") no-repeat;
  background-size: cover;
}

.node-dataCount {
  background: url("../background/u1243.svg") no-repeat;
  background-size: cover;
}
.node-generateReport {
  background: url("../background/u1248.svg") no-repeat;
  background-size: cover;
}
</style>
